<template>
    <a-row :gutter="10">
        <!--上面表格-->
        <a-col :md="24" :sm="24" style="margin-bottom: 5px">
            <a-card :bordered="false">
                <!--
                    查询区域
                    @keyup.enter.native 回车触发事件
                -->
                <div class="table-page-search-wrapper">
                    <h2 class="text-center  margin-bottom">机构信息列表</h2>
                    <a-form layout="inline" @keyup.enter.native="searchQuery">
                        <a-row :gutter="24">
                            <a-col :md="6" :sm="24">
                                <a-form-item label="机 构 名 称">
                                    <a-input v-model="queryParam.customerName" placeholder="机构名称"/>
                                </a-form-item>
                            </a-col>
                            <a-col :md="6" :sm="24">
                                <a-form-item label="机构负责人">
                                    <a-input v-model="queryParam.leadername" placeholder="负责人"/>
                                </a-form-item>
                            </a-col>
                            <a-col :md="6" :sm="24">
                                <a-form-item label="负责人电话">
                                    <a-input v-model="queryParam.leaderphone" placeholder="负责人电话"/>
                                </a-form-item>
                            </a-col>
                            <template v-if="toggleSearchStatus">
                                <!--显示处置单位筛选条件：query:company:select:auth 通过后台菜单配置角色是否显示-->
                                <a-col :md="6" :sm="24" v-has="'query:company:select:auth'">
                                    <a-form-item label="处 置 单 位">
                                        <select-company-list @change="changeCompany"></select-company-list>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-if="showSelectArea">
                                    <a-form-item label="区 域 查 询">
                                        <select-area ref="selectAreaRef" @change="changeArea"></select-area>
                                    </a-form-item>
                                </a-col>

                                <!--AUTH.CUS_AUDIT_STATE权限控制-->
                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_AUDIT_STATE">
                                    <a-form-item label="审 核 状 态">
                                        <a-select placeholder="审核状态" v-model="queryParam.audit">
                                            <a-select-option value="">全部</a-select-option>
                                            <a-select-option value="0">待审核</a-select-option>
                                            <a-select-option value="1">审核通过</a-select-option>
                                            <a-select-option value="2">审核未通过</a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_OPERATION_STATE">
                                    <a-form-item label="营 业 状 况">
                                        <a-select placeholder="营业状况" v-model="queryParam.operationState">
                                            <a-select-option value="">全部</a-select-option>
                                            <a-select-option value="0">正常营业</a-select-option>
                                            <a-select-option value="1">暂停营业</a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_ORGANIZATION_LEVEL">
                                    <a-form-item label="机 构 等 级">
                                        <a-select placeholder="机构等级" v-model="queryParam.organizationLevel">
                                            <a-select-option value="">全部</a-select-option>
                                            <!--organizationLevelList是main.js中定义的全局数据，要使用this.$config来调用-->
                                            <a-select-option v-for="item in this.$config.organizationLevelList"
                                                             :key="item.value"
                                                             :value="item.value">
                                                {{ item.label }}
                                            </a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_ORGANIZATION_SUPERVISE">
                                    <a-form-item label="监 管 类 别">
                                        <a-select placeholder="监管类别" v-model="queryParam.organizationSupervise">
                                            <a-select-option value="">全部</a-select-option>
                                            <a-select-option v-for="item in this.$config.organizationSuperviseList"
                                                             :key="item.value" :value="item.value">
                                                {{ item.label }}
                                            </a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_UPLOAD_PROVINCE_SYSTEM">
                                    <a-form-item label="固 废 系 统">
                                        <a-select placeholder="上传固废系统" v-model="queryParam.whetherToUpload">
                                            <a-select-option value="">全部</a-select-option>
                                            <a-select-option value="0">不上传</a-select-option>
                                            <a-select-option value="1">上传省固废</a-select-option>
                                            <a-select-option value="2">上传市固废</a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_LINK_BLUETOOTH">
                                    <a-form-item label="连接蓝牙秤">
                                        <a-select placeholder="是否连接蓝牙秤" v-model="queryParam.linkBluetooth">
                                            <a-select-option value="">全部</a-select-option>
                                            <a-select-option value="0">不连接</a-select-option>
                                            <a-select-option value="1">连接蓝牙秤</a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_LINK_BLUETOOTH">
                                    <a-form-item label="废物填报类型">
                                        <a-select placeholder="废物填报类型" v-model="queryParam.wasteFormType">
                                            <a-select-option :value="null">默认值</a-select-option>
                                            <a-select-option :value="0">扫描二维码扎带</a-select-option>
                                            <a-select-option :value="1">打印二维码标签</a-select-option>
                                            <a-select-option :value="2">全部类型</a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>

                                <a-col :md="6" :sm="24" v-has="AUTH.CUS_TYPE">
                                    <a-form-item label="机 构 类 型">
                                        <a-select placeholder="机构类型" v-model="queryParam.customerType">
                                            <a-select-option value="">全部</a-select-option>
                                            <a-select-option v-for="(val,key) in CUSTOMER_TYPE" :key="key" :value="val.value">
                                                {{val.name}}
                                            </a-select-option>
                                        </a-select>
                                    </a-form-item>
                                </a-col>
                            </template>

                            <a-col :md="6" :sm="8">
                                <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                                  <a @click="handleToggleSearch" style="margin-left: 8px">
                                    {{ toggleSearchStatus ? '收起条件' : '展开条件' }}
                                    <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
                                  </a>
                                </span>
                            </a-col>

                        </a-row>
                    </a-form>
                </div>
                <!-- 查询区域-END -->

                <!-- 操作按钮区域 -->
                <div class="table-operator" style="display: flex;justify-content: space-between;align-items: center;">
                    <div>
                        <a-button v-has="'customer:manager:add:info'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
                        <a-button type="primary" @click="searchQuery" icon="search">查询数据列表</a-button>
                        <a-button type="primary" @click="resetForm">重置查询</a-button>
                    </div>
                    <div>
                        <a-button type="primary" icon="printer" v-print="'#printTableList'">打印</a-button>
                        <a-button v-has="'customer:manager:add:export:excel'" type="primary" icon="download"
                                  @click="handleMwExportXls">
                            导出Excel
                        </a-button>
                    </div>
                </div>

                <!-- table区域-begin -->
                <div>
                    <a-table
                            style="height:330px;"
                            ref="table"
                            size="small"
                            :scroll="{x: true}"
                            bordered
                            rowKey="id"
                            :columns="columns"
                            :dataSource="dataSource"
                            :pagination="ipagination"
                            :loading="loading"
                            :rowSelection="{selectedRowKeys: selectedRowKeys1, onChange: onSelectChange1, type:'radio'}"
                            class="j-table-force-nowrap"
                            @change="handleTableChange">

                        <template slot="htmlSlot" slot-scope="text">
                            <div v-html="text"></div>
                        </template>
                        <template slot="imgSlot" slot-scope="text">
                            <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                            <img v-else :src="getImgView(text)" height="25px" alt=""
                                 style="max-width:80px;font-size: 12px;font-style: italic;"/>
                        </template>
                        <template slot="fileSlot" slot-scope="text">
                            <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                            <a-button
                                    v-else
                                    :ghost="true"
                                    type="primary"
                                    icon="download"
                                    size="small"
                                    @click="downloadFile(text)">
                                下载
                            </a-button>
                        </template>

                        <!--操作栏的按钮控制-->
                        <span slot="action" slot-scope="text, record">
                            <a v-has="'customer:manager:edit:info'" @click="handleEdit(record)">编辑</a>
                            <a-divider v-has="'customer:manager:edit:info'" type="vertical"/>
                             <a v-has="'customer:manager:audit:info'" style="color: deepskyblue;" v-if="record.audit == 0"
                                @click="showModal(record)">审核</a>
                            <a v-has="'customer:manager:audit:info'" style="color: #848383;cursor:not-allowed" v-else>审核</a>
                            <a-divider v-has="'customer:manager:audit:info'" type="vertical"/>
                            <a style="color: #a2f9ef;" v-has="'customer:dengjizheng'"
                               @click="toPrintPage(record)">登记证</a>
                            <a-divider v-has="'customer:dengjizheng'" type="vertical"/>
                             <a style="color: deepskyblue;" v-has="'customer:enforce:law'"
                                @click="toPrintEnforcePage(record)">执法凭证</a>
                            <a-divider v-has="'customer:enforce:law'" type="vertical"/>
                            <span v-has="'customer:suspension:of:business:apply:hospital:menu'">
                                <a style="color: #c72121;"
                                   v-if="record.operationState == 0"
                                   @click="toPage(record,'apply0')">暂停营业申请</a>
                                <a style="color: orange;"
                                   v-if="record.operationState == 1"
                                   @click="toPage(record,'apply1')">恢复营业申请</a>
                                 <a-divider type="vertical"/>
                            </span>

                          <a-dropdown>
                            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
                            <a-menu slot="overlay">
                              <a-menu-item v-has="'customer:manager:qrcode'">
                                    <a class="margin-right-sm" style="color: #05f305;"
                                       @click="createQrCode(record)">机构详情</a>
                              </a-menu-item>
                              <a-menu-item v-has="'customer:manager:query:department'">
                                    <a class="margin-right-sm" style="color: darkcyan;"
                                       @click="toDepartmentListPage(record)">机构部门</a>
                              </a-menu-item>
                                <a-menu-item v-has="'customer:add:account:password'">
                                    <a class="margin-right-sm" style="color: orange;"
                                       @click="toAddAccountPage(record)">添加账号密码</a>
                              </a-menu-item>
                                <a-menu-item v-has="'customer:add:medical:resources'">
                                <a class="margin-right-sm" style="color: #21A5FF;"
                                   @click="toAddMedicalPage(record)">医资信息</a>
                                </a-menu-item>
                                <a-menu-item v-has="'customer:add:medical:resources:code'">
                                <a class="margin-right-sm" style="color: limegreen;"
                                   @click="getQrCode(record)">执法二维码</a>
                                </a-menu-item>

                            </a-menu>
                          </a-dropdown>
                        </span>

                    </a-table>
                </div>

                <hc-recycle-customer-info-modal ref="modalForm" @ok="modalFormOk"></hc-recycle-customer-info-modal>

                <!--机构审核页面-->
                <a-modal v-if="editData" v-model="visible"
                         :title="'【'+editData.customerName+'】机构信息审核'"
                         width="80%"
                >
                    <a-form layout="inline">
                        <a-row :gutter="24">
                            <a-col :sm="24">
                                <a-form-item label="机构名称">
                                    <div class="text-white">{{editData.customerName}}</div>
                                </a-form-item>
                            </a-col>
                            <a-col :sm="24">
                                <a-form-item label="机构编码">
                                    <div class="text-white">{{editData.customerNumber || ''}}</div>
                                </a-form-item>
                            </a-col>
                            <a-col :sm="24">
                                <a-form-item label="负责人姓名">
                                    <div class="text-white">{{editData.leadername || ''}}</div>
                                </a-form-item>
                            </a-col>
                            <a-col :sm="24">
                                <a-form-item label="负责人电话">
                                    <div class="text-white">{{editData.leaderphone || ''}}</div>
                                </a-form-item>
                            </a-col>
                            <a-col :sm="24">
                                <a-form-item label="机构地址">
                                    <div class="text-white">{{editData.address || ''}}</div>
                                </a-form-item>
                            </a-col>
                            <a-col :sm="24">
                                <a-form-item label="审核备注"></a-form-item>
                            </a-col>
                            <a-col :sm="24">
                                <a-textarea style="width: 100%;" v-model="auditRemark" placeholder="审核备注" :rows="4"/>
                            </a-col>
                        </a-row>
                    </a-form>
                    <template slot="footer">
                        <a-button key="back" @click="handleCancel">
                            关闭弹窗
                        </a-button>
                        <a-button type="primary" :loading="loading" @click="handleOk(1)">
                            审核通过
                        </a-button>
                        <a-button type="danger" :loading="loading" @click="handleOk(2)">
                            审核未通过
                        </a-button>
                    </template>
                </a-modal>

                <!--机构详情-->
                <a-modal v-if="editData"
                         v-model="showQrCode"
                         :title="'【'+editData.customerName+'】机构二维码'"
                         width="100%"
                >
                    <a-form layout="inline">
                        <a-row :gutter="24">
                            <a-col :span="12">
                                <a-col :sm="24">
                                    <a-form-item label="机构名称">
                                        <div class="text-white">{{editData.customerName}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="机构编码">
                                        <div class="text-white">{{editData.customerNumber || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="负责人姓名">
                                        <div class="text-white">{{editData.leadername || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="负责人电话">
                                        <div class="text-white">{{editData.leaderphone || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="机构地址">
                                        <div class="text-white">{{editData.address || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="机构二维码">
                                        <div class="qrCodeRef" ref="qrCodeRef"></div>
                                    </a-form-item>
                                </a-col>
                            </a-col>
                            <a-col :span="12">
                                <a-col :sm="24">
                                    <a-form-item label="营业执照编号">
                                        <div class="text-white" style="font-weight: bold;">{{editData.businessLicenseNumber || '--'}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="营业执照图片" v-if="editData.businessLicense">
                                        <img class="j-editable-image" :src="getImgView(editData.businessLicense)" alt="无图片" style="width: 100%;"/>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="执业许可证编号">
                                        <div class="text-white" style="font-weight: bold;">{{editData.licenceNumber || '--'}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="执业许可证图片" v-if="editData.licence">
                                        <img class="j-editable-image" :src="getImgView(editData.licence)" alt="无图片" style="width: 100%;"/>
                                    </a-form-item>
                                </a-col>
                            </a-col>
                        </a-row>

                    </a-form>
                    <template slot="footer">
                        <a-button key="back" @click="closeQrCodeModel()">
                            关闭弹窗
                        </a-button>
                        <a-button type="primary" :loading="loading" @click="downloadCodeImg()">
                            下载二维码
                        </a-button>
                    </template>
                </a-modal>

                <!--打印客户登记证-->
                <print-customer-data ref="printRef"></print-customer-data>

                <!--  打印执法凭证v2 -->
                <print-customer-data-v2 ref="printRefV2"></print-customer-data-v2>

                <!--部门机构管理-->
                <department-list-model ref="departmentRef"></department-list-model>

                <!--医资信息-->
                <customer-medical-info ref="medicalRef"></customer-medical-info>

                <!--  查看执法二维码   -->
                <customer-qr-code ref="customerCodeRef"></customer-qr-code>

                <!--添加省固废账号密码页面-->
                <a-modal v-model="showInfo"
                         v-if="editData"
                         :title="'【'+editData.customerName+'】添加省/市固废账号密码'"
                         width="60%"
                >
                    <a-row>
                        <a-col :sm="24" :md="14" style="margin-right: 10px;">
                            <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
                                <a-form-item label="登录账户" required >
                                    <a-input v-decorator="['login', { rules: [{ required: true, message: '请输入账户名称!' }] }]"/>
                                </a-form-item>
                                <a-form-item label="登录密码" required>
                                    <a-input v-decorator="['password', { rules: [{ required: true, message: '请输入登录密码!' }] }]"/>
                                </a-form-item>
                            </a-form>
                            <div style="margin:10px 0px 0px 60px;">
                                <a-button style="margin-right: 10px" type="primary" icon="plus" @click="addUserInfo">添加</a-button>
                                <a-button style="margin-right: 10px" type="primary" @click="showDepartmentsInfo">同步科室</a-button>
                                <a-button type="primary" @click="clearBtn">清除</a-button>
                            </div>
                            <!--  点击同步科室后显示的科室信息   -->
                        </a-col>
                        <a-col :sm="24" :md="8">
                            <a-card title="操作结果">
                                <div class="resultMeg">
                                    {{this.message}}
                                </div>
                                <a-list size="small" bordered :data-source="departments" v-if="departments.length>0">
                                    <a-list-item slot="renderItem" slot-scope="item, index">
                                        <span class="text-white" >{{`${item.value} - ${item.label}`}}</span>
                                    </a-list-item>
                                </a-list>
                            </a-card>
                        </a-col>
                    </a-row>
                    <template slot="footer">
                        <a-button key="back" @click="handleShowInfo">
                            关闭
                        </a-button>
                        <a-button type="primary"  @click="handleShowInfoOk">
                            确定
                        </a-button>
                    </template>
                </a-modal>

                <!--机构信息列表页面打印-->
                <div v-show="false">
                    <div id="printTableList">
                        <h2 style="text-align: center;font-weight: bold;">
                            机构信息列表
                        </h2>
                        <h3>打印时间 ： {{new Date().FormatDate()}}</h3>
                        <a-table
                                size="small"
                                bordered
                                rowKey="id"
                                :columns="printColumns"
                                :dataSource="dataSource"
                                :pagination="false"
                        >
                            <template slot="htmlSlot" slot-scope="text">
                                <div style="color: black !important;" v-html="text"></div>
                            </template>
                        </a-table>
                    </div>
                </div>

                <!--显示绑定负责人的界面-->
                <a-modal v-if="bandUserInfo.userInfo ? true : false"
                         v-model="bandUserInfo.userInfo ? true : false"
                         :title="'【'+bandUserInfo.customer.customerName+'】绑定的负责人信息'"
                         width="50%"
                         @cancel="() => this.bandUserInfo = {}"
                >
                    <a-form layout="inline">
                        <a-row :gutter="24">
                            <a-col :span="24" v-if="bandUserInfo.userInfo">
                                <a-col :sm="24">
                                    <a-form-item label="负责人ID">
                                        <div class="text-white">{{bandUserInfo.userInfo.id || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="负责人账户">
                                        <div class="text-white">{{bandUserInfo.userInfo.username || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="负责人昵称">
                                        <div class="text-white">{{bandUserInfo.userInfo.realname || ''}}</div>
                                    </a-form-item>
                                </a-col>
                                <a-col :sm="24">
                                    <a-form-item label="负责人角色">
                                        <div class="text-white">{{bandUserInfo.userInfo.roleName || ''}}</div>
                                    </a-form-item>
                                </a-col>
                            </a-col>
                        </a-row>
                    </a-form>
                    <template slot="footer" >
                        <a-button key="back" @click="() => this.bandUserInfo = {}">
                            关闭弹窗
                        </a-button>
                    </template>
                </a-modal>

            </a-card>
        </a-col>

        <!--下面表格-->
        <a-col :md="24" :sm="24" v-if="this.bottomcolval == 1">
            <div>
                <div style="text-align: right;">
                    <a-icon type="close-circle" @click="hideBottomTable"/>
                </div>

                <customer-info-img-two :customerNumber="currentCustomerNumber"
                     :customerName="currentCustomerName"
                     :businessLicense="businessLicense"
                     :businessLicenseNumber="businessLicenseNumber"
                     :licence="licence"
                     :licenceNumber="licenceNumber"
                />
            </div>
        </a-col>


    </a-row>

</template>
<script type="text/javascript">
new QRCode(document.getElementsByClassName("qrCodeRef"), "https://github.com/KeeeX/qrcodejs");
</script>
<script>

    import '@/assets/less/TableExpand.less'
    import { mixinDevice } from '@/utils/mixin'
    import { JeecgListMixin } from '@/mixins/JeecgListMixin'
    import HcRecycleCustomerInfoModal from './modules/HcRecycleCustomerInfoModal'
    import PrintCustomerData from './modules/PrintCustomerData'
    import PrintCustomerDataV2 from './modules/PrintCustomerDataV2'
    import DepartmentListModel from './modules/DepartmentListModel'
    import SelectArea from '@/components/Jane/SelectArea'
    import SelectCompanyList from '@/components/Jane/SelectCompanyList'
    import { downloadFile, getAction } from '@/api/manage'
    import CustomerInfoImgTwo from '@/components/yang/CustomerInfoImgTwo'

    import QRCode from 'qrcodejs2'
    import { GET_USER_AUTH } from '@/utils/util'
    import CustomerMedicalInfo from '@jyb_v3/customer/CustomerMedicalInfo'
    import CustomerQrCode from '@jyb_v3/customer/modules/CustomerQrCode'

    // 机构类型
    const CUSTOMER_TYPE = [
        {
            value: '1',
            name: '输液瓶类型'
        },
        {
            value: '2',
            name: '医疗废物类型'
        }
        // {
        //     value : '3',
        //     name : "输液瓶和医疗废物类型",
        // },
        // {
        //     value : '4',
        //     name : "无服务类型",
        // },
    ]

    export default {
        name: 'HcRecycleCustomerInfoList',
        mixins: [JeecgListMixin, mixinDevice],
        components: {
            CustomerQrCode,
            CustomerMedicalInfo,
            HcRecycleCustomerInfoModal,
            PrintCustomerData,
            SelectArea,
            SelectCompanyList,
            DepartmentListModel,
            CustomerInfoImgTwo,
            PrintCustomerDataV2
        },
        data() {
            return {
                description: '医疗机构表管理页面',
                // 表头
                columns: [],
                printColumns: [],
                // 添加省固废账号密码
                showInfo: false,
                // 用户省固废账号密码
                login:'',
                password: '',
                form: this.$form.createForm(this, { name: 'coordinated' }),
                // 科室信息
                departments:[],
                // 操作结果
                message:'',
                url: {
                    list: '/hc/hcRecycleCustomerInfo/list',
                    delete: '/hc/hcRecycleCustomerInfo/delete',
                    exportXlsUrl: '/hc/Regulatory/exportRegulatoryCustomer',
                    queryUserById: '/sys/user/queryById',
                },
                queryParam: {
                    customerName: '',
                    leadername: '',
                    leaderphone: '',
                    cityCode: '',
                    areaCode: '',
                    companysId: '',
                    audit: '',
                    operationState: '',
                    organizationLevel: '',
                    organizationSupervise: '',
                    whetherToUpload: '',
                    linkBluetooth: '',
                    customerType: ''
                },
                bandUserInfo : {},
                editData: null,
                visible: false,
                auditRemark: '',
                showQrCode: false,
                qrcodeImgUrl: '',
                CUSTOMER_TYPE,
                // 机构信息页面权限控制标识
                AUTH: {
                    CUS_SHOW_NUMBER: 'customer:show:number', // 机构编码
                    BUSINESS_LICENSE_NUMBER: 'business:license:number', // 营业执照编码
                    CUS_AUDIT_STATE: 'customer:manager:by:audit:state', // 机构审核状态
                    CUS_OPERATION_STATE: 'customer:manager:operation:state', // 机构营业状态
                    CUS_ORGANIZATION_LEVEL: 'customer:organization:level', // 机构等级
                    CUS_ORGANIZATION_SUPERVISE: 'customer:organization:supervise', // 机构监管类别
                    CUS_TABLE_OPTION: 'customer:table:option', // 机构table尾部【操作】列
                    CUS_UPLOAD_PROVINCE_SYSTEM: 'customer:upload:province:system', // 机构废物是否上传【省固废系统】
                    CUS_LINK_BLUETOOTH: 'customer:is:link:bluetooth', // 机构填写废物信息是否连接蓝牙秤
                    CUS_TYPE: 'customer:manager:type',  // 1输液瓶   2医废   3输液瓶和医废  4无服务类型
                    CUS_BIND_MANAGER_USER : 'customer:bind:manager:user', //机构是否绑定负责人
                    CUS_ADD_ACCOUNT_PASSWORD: 'customer:add:account:password',// 机构添加省固废账号密码
                    BNKMUN_SHOW_NUMBER: 'bnkmun:show:number',// 市固废编码
                    CUS_ADD_MEDICAL_RESOURCES: 'customer:add:medical:resources',// 医资信息
                },
                selectedRowKeys1: [],
                bottomcolval : 0,
                ipagination: {
                    current: 1, // 当前页
                    pageSize: 5, // 一页的数据限制
                },
                currentCustomerNumber:'',// 选中的医院编号
                currentCustomerName:'',// 选中的医院名称
                checkedNum : '',// 选中的类型
                licence: '', //许可证照片地址
                licenceNumber:'',//许可证编号
                businessLicense: '', //营业执照照片地址
                businessLicenseNumber:'',//营业执照编号
                checkPreImg : null,
            }
        },
        created() {
            this.initData()
        },
        mounted() {
        },
        computed: {
            // 控制是否显示区域查询，默认是显示
            showSelectArea: function() {
                let state = true
                let userInfo = this.$store.getters.userInfo
                // 如果用户存在provinceCode、cityCode、areaCode 则不显示
                if (userInfo.provinceCode && userInfo.cityCode && userInfo.areaCode) {
                    state = false
                }
                return state
            },
        },
        methods: {
            // 配置初始化信息
            initDictConfig() {
                let that = this
                let columns = []
                if (GET_USER_AUTH(this.AUTH.CUS_ORGANIZATION_LEVEL)) {
                    columns.push({
                        title: '机构等级',
                        align: 'center',
                        dataIndex: 'organizationLevel',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: ' ',
                                attrs: {}
                            }
                            let info = that.$config.getOrgLevel(value)
                            if (info) {
                                if (value == 0) {
                                    obj['children'] =
                                <span
                                    style = 'color:#47d947;' > { info['label'] } </span>
                                } else if (value == 1) {
                                    obj['children'] =
                                <
                                    span
                                    style = 'color:deepskyblue;' > { info['label'] } </span>
                                } else if (value == 2) {
                                    obj['children'] =
                                <
                                    span
                                    style = 'color:orange;' > { info['label'] } </span>
                                } else if (value == 3) {
                                    obj['children'] =
                                <
                                    span
                                    style = 'color:#d42c05;' > { info['label'] } </span>
                                }
                            }
                            return obj
                        }
                    })
                }
                if (GET_USER_AUTH(this.AUTH.CUS_ORGANIZATION_SUPERVISE)) {
                    columns.push({
                        title: '监管类别',
                        align: 'center',
                        dataIndex: 'organizationSupervise',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: ' ',
                                attrs: {}
                            }
                            let info = that.$config.getOrgSupervise(value)
                            if (info) {
                                if (value == 0) {
                                    obj['children'] =
                                <
                                    span
                                    style = 'color:#47d947;' > { info['label'] } </span>
                                } else if (value == 1) {
                                    obj['children'] =
                                <
                                    span
                                    style = 'color:deepskyblue;' > { info['label'] } </span>
                                } else if (value == 2) {
                                    obj['children'] =
                                <
                                    span
                                    style = 'color:orange;' > { info['label'] } </span>
                                }
                            }
                            return obj
                        }
                    })
                }
                if (GET_USER_AUTH(this.AUTH.CUS_TYPE)) {
                    columns.push({
                        title: '机构类型',
                        align: 'center',
                        dataIndex: 'customerType',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            let info = CUSTOMER_TYPE.find(val => val.value == value)
                            if (info) {
                                return info['name']
                            }
                            return '医疗废物类型'
                        }
                    })
                }
                if (GET_USER_AUTH(this.AUTH.CUS_AUDIT_STATE)) {
                    columns.push({
                        title: '审核状态',
                        align: 'center',
                        dataIndex: 'audit',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: ' ',
                                attrs: {}
                            }
                            if (value == 0) {
                                obj['children'] =
                            <
                                span
                                style = 'color:#05f305;' > 待审核 </span>
                            } else if (value == 1) {
                                obj['children'] =
                            <
                                span
                                style = 'color:#e5e5ff;' > 审核通过 </span>
                            } else if (value == 2) {
                                obj['children'] =
                            <
                                span
                                style = 'color:red;' > 审核未通过 </span>
                            }
                            return obj
                        }
                    })
                }
                if (GET_USER_AUTH(this.AUTH.CUS_OPERATION_STATE)) {
                    columns.push({
                        title: '营业状态',
                        align: 'center',
                        dataIndex: 'operationState',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: '-',
                                attrs: {}
                            }
                            if (value == 1) {
                                obj['children'] =
                            <
                                span
                                style = 'color:orange;' > 暂停营业 </span>
                            } else if (value == 0) {
                                obj['children'] =
                            <
                                span
                                style = 'color:deepskyblue;' > 正常营业 </span>
                            }
                            return obj
                        }
                    })
                }

                if (GET_USER_AUTH(this.AUTH.CUS_LINK_BLUETOOTH)) {
                    columns.push({
                        title: '连接蓝牙秤',
                        align: 'center',
                        dataIndex: 'linkBluetooth',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: '-',
                                attrs: {}
                            }
                            if (value == 1) {
                                obj['children'] =
                            <
                                span
                                style = 'color:deepskyblue;' > 连接蓝牙秤 </span>
                            } else if (value == 0) {
                                obj['children'] =
                            <
                                span
                                style = 'color:orange;' > 不连接 </span>
                            }
                            return obj
                        }
                    })
                    columns.push({
                        title: '废物填报类型',
                        align: 'center',
                        dataIndex: 'wasteFormType',
                        customRender: function(value, row, index) {
                            if (value == 0) {
                                return '二维码扎带'
                            } else if (value == 1) {
                                return '打印条码'
                            } else if (value == 2) {
                                return '全部'
                            }
                            return '--'
                        }
                    })

                }
                if (GET_USER_AUTH(this.AUTH.CUS_BIND_MANAGER_USER)) {
                    columns.push({
                        title: '绑定负责人',
                        align: 'center',
                        dataIndex: 'userId',
                        key: 'userId',
                        // scopedSlots: { customRender: 'htmlSlot' },
                        // 需要有点击事件的话就需要使用 link
                        scopedSlots: { customRender: 'link' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: <span style = 'color:#bbb;'> 未绑定 </span>,
                                attrs: {}
                            }
                            if (value) {
                                obj['children'] = <span style = 'font-weight:600;color:deepskyblue;text-decoration: underline;'
                                onclick = {()  => that.openInfo(row) }> 已绑定 </span>
                            }
                            return obj
                        }
                    })
                }
                if (GET_USER_AUTH(this.AUTH.CUS_TABLE_OPTION)) {
                    columns.push({
                        title: '操作',
                        dataIndex: 'action',
                        align: 'center',
                        scopedSlots: { customRender: 'action' }
                    })
                }

                this.columns = [
                    {
                        title: '机构名称',
                        align: 'center',
                        dataIndex: 'customerName',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: value,
                                attrs: {}
                            }
                            if (row.whetherToUpload == 1) {
                                obj['children'] =
                            <
                                span
                                style = 'fontWeight:bold;color:#469BE3;' > { value } </span>
                            } else if (row.whetherToUpload == 2) {
                                obj['children'] =
                            <
                                span
                                style = 'fontWeight:bold;color:#dbbff9;' > { value } </span>
                            }
                            return obj
                        }
                    },
                    {
                        title: '负责人',
                        align: 'center',
                        dataIndex: 'leadername'
                    },
                    {
                        title: '负责人电话',
                        align: 'center',
                        dataIndex: 'leaderphone'
                    },
                    {
                        title: '机构地址',
                        align: 'center',
                        dataIndex: 'address',
                        customRender: function(t, r, index) {
                            // 只显示机构的省/市/县
                            return `${r.province || ''}${r.city || ''}${r.area || ''}`
                        }
                    },
                    ...columns
                ]
                if (GET_USER_AUTH(this.AUTH.BNKMUN_SHOW_NUMBER)) {
                    this.columns.unshift({
                        title: '市固废编号',
                        align: 'center',
                        dataIndex: 'bnkMunicipalId'
                    })
                }
                if (GET_USER_AUTH(this.AUTH.BUSINESS_LICENSE_NUMBER)) {
                    // unshift 数组头部插入;
                    this.columns.unshift({
                        title: '许可证编号',
                        align: 'center',
                        dataIndex: 'licenceNumber'
                    })
                }
                if (GET_USER_AUTH(this.AUTH.CUS_SHOW_NUMBER)) {
                    this.columns.unshift({
                        title: '机构编号',
                        align: 'center',
                        dataIndex: 'customerNumber'
                    })
                }
                this.columns.unshift({
                    title: '序号',
                    dataIndex: '',
                    key: 'rowIndex',
                    align: 'center',
                    customRender: function(t, r, index) {
                        return parseInt(index) + 1
                    }
                })


                // 打印的列头部
                this.printColumns = [
                    {
                        title: '机构名称',
                        align: 'center',
                        dataIndex: 'customerName',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: value,
                                attrs: {}
                            }
                            if (row.whetherToUpload) {
                                obj['children'] =
                            <
                                span
                                style = 'fontWeight:bold;color:#fbf5b4;' > { value } </span>
                            }
                            return obj
                        }
                    },
                    {
                        title: '负责人',
                        align: 'center',
                        dataIndex: 'leadername'
                    },
                    {
                        title: '负责人电话',
                        align: 'center',
                        dataIndex: 'leaderphone'
                    },
                    {
                        title: '机构地址',
                        align: 'center',
                        dataIndex: 'address',
                        customRender: function(t, r, index) {
                            return `${r.province || ''}${r.city || ''}${r.area || ''}`
                        }
                    },
                    {
                        title: '机构等级',
                        align: 'center',
                        dataIndex: 'organizationLevel',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: ' ',
                                attrs: {}
                            }
                            let info = that.$config.getOrgLevel(value)
                            if (info) {
                                obj['children'] = info['label']
                            }
                            return obj
                        }
                    }
                ]

            },
            // 初始化数据
            initData: function() {
                for (let i in this.queryParam) {
                    this.queryParam[i] = ''
                }
                // 获取到用户登陆的信息
                let userInfo = this.$store.getters.userInfo
                // 如果用户存在区县编码、处置单位Id编号，则赋值
                if (userInfo.cityCode) {
                    this.queryParam.cityCode = userInfo.cityCode
                }
                if (userInfo.areaCode) {
                    this.queryParam['areaCode'] = userInfo.areaCode
                }
                if (userInfo.companysId) {
                    this.queryParam['companysId'] = userInfo.companysId
                }
                // this.queryParam.customerName = '观山湖斯凯颜医疗美容诊所';

                // 默认查询医疗废物类型
                this.queryParam.customerType = ''
                let ref = this.$refs.selectAreaRef
                if (ref && ref.clearSelectArea != undefined) {
                    ref.clearSelectArea()
                }

            },

            // 获取二维码
             getQrCode(item) {
                let ref = this.$refs.customerCodeRef
                if (ref) {
                    ref.show(item)
                }
            },

            // 查看绑定的人员信息
            async openInfo(info){
                this.bandUserInfo = {};
                let userId = info.userId;
                let res = await getAction(this.url.queryUserById,{id : userId});

                if(res.success && res.result){
                    this.bandUserInfo = {
                        customer : info,
                        userInfo : res.result
                    };
                }
            },

            // 选择区域
            async changeArea({ area, city }) {
                if (city) {
                    this.queryParam.cityCode = city
                }
                if (area) {
                    this.queryParam.areaCode = area
                }
            },
            //  选择处置单位
            async changeCompany(value) {
                this.queryParam.companysId = value
            },
            // 重置表单按钮
            resetForm: function() {
                this.initData()
                this.searchQuery()
            },
            // 查询数据按钮
            searchQuery: function() {
                this.selectedRowKeys = []
                this.selectionRows = []
                this.loadData(1)
            },
            // 打印客户溯源信息登记证
            toPrintPage: function(row) {
                let ref = this.$refs.printRef
                if (ref) {
                    ref.creatQrCode(row)
                }
            },
            // 打印执法凭证
            toPrintEnforcePage:function(row){
                let ref = this.$refs.printRefV2
                if (ref) {
                    ref.creatQrCode(row)
                }
            },
            // 查看部门信息管理
            toDepartmentListPage: function(row) {
                let ref = this.$refs.departmentRef
                if (ref) {
                    ref.show(row)
                }
            },
            // 查看医资信息
            toAddMedicalPage:function(row){
                let ref = this.$refs.medicalRef
                if (ref) {
                    ref.show(row)
                }
            },
            //打开省固废账号密码
            async toAddAccountPage(row) {
                this.showInfo = true;
                this.message = null;
                this.departments = [];
                this.editData = row;
                let params = {
                    customerNumber: this.editData.customerNumber
                }
                let res = await getAction('hc/gzhbUser/queryByCustomerId',params)
                if (res && res.success) {
                    this.login = res.result.loginname;
                    this.password = res.result.password;
                } else {
                    this.login = '';
                    this.password = '';
                }
                this.form.setFieldsValue({
                    login: this.login,
                    password: this.password,
                })
            },
            // 关闭添加省固废账号密码页面
            handleShowInfo(e){
                this.showInfo = false
            },
            // 确定省固废账号密码页面
            handleShowInfoOk(){
                this.showInfo = false
                this.editData = null
            },
            // 添加省固废账号密码
            async addUserInfo(e){
                e.preventDefault()
                let _this = this
                this.form.validateFields(async (err, values) => {
                    if (!err) {
                        let params = {
                            customerNumber: this.editData.customerNumber,
                            login : values.login,
                            password : values.password,
                        };
                        let res = await getAction('hc/hcRecycleCustomerInfo/addGzhbUserByNumber', params)
                        _this.message = JSON.stringify(res.message)
                    }
                })

            },
            // 同步省/市固废科室信息
            async showDepartmentsInfo(){
                let params = {
                    customerNumber: this.editData.customerNumber,
                }
                let res = await getAction('hc/hcRecycleMunicipal/batchUpdateDapartment', params)
                if (res && res.success) {
                    let data = res.result || []
                    let arr = []
                    data.forEach((item) => {
                        arr.push({
                            label: item['bnkDepartmentId'],
                            value: item['departmentName']
                        })
                    })
                    this.departments = arr
                    this.message = res.message
                } else {
                    this.message = res.message
                }
            },
            // 清除按钮
            async clearBtn(e){
                e.preventDefault()
                let _this = this
                this.form.validateFields(async (err, values) => {
                    if (!err) {
                        let params = {
                            customerNumber: this.editData.customerNumber,
                        };
                        let res = await getAction('/hc/hcRecycleCustomerInfo/clearGzhbUserByNumber', params)
                        if(res && res.success){
                            _this.message = JSON.stringify(res.result)
                            _this.departments = ''
                            this.form.setFieldsValue({
                                login: '',
                                password: '',
                            })
                        }
                    }
                })
                // let params = {
                //     customerNumber: this.editData.customerNumber,
                // }
                // let res = await getAction('/hc/hcRecycleCustomerInfo/clearGzhbUserByNumber', params)
                // if(res && res.success){
                //     this.login = ''
                //     this.password = ''
                //     this.message = JSON.stringify(res.message)
                // }
            },
            showModal(row) {
                this.visible = true
                this.editData = row
                this.message = null
            },
            handleCancel(e) {
                this.visible = false
                this.editData = null
                this.message = null
                this.auditRemark = ''
            },


            async handleOk(state = 1) {
                if (state == 2 && this.auditRemark == '') {
                    this.$message.warn('请填写【审核未通过】的原因！')
                    return
                }
                let params = {
                    id: this.editData.id,
                    audit: state,
                    auditRemark: this.auditRemark || ''
                }
                this.loading = true
                let res = await getAction('hc/hcRecycleCustomerInfo/customerInfoAudit', params)
                if (res && res.success) {
                    this.visible = false
                    this.loading = false
                    this.auditRemark = ''
                    this.$message.success(res.message || '审核信息提交成功！')
                } else {
                    this.$message.warn(res.message || '审核失败！')
                }
                this.loadData()
            },

            // 生成二维码
            createQrCode: function(item) {
                this.showQrCode = true
                this.editData = item

                setTimeout(() => {
                    document.getElementsByClassName('qrCodeRef')[0].innerHTML = ''
                    let ref = this.$refs.qrCodeRef
                    if (ref) {
                        // encodeURI("bnkhospital_" + hospital_id + "_" + 医院名称)
                        let text = encodeURI(`bnkhospital_${item.customerNumber}_${item.customerName}`)
                        console.log('text',text)
                        new QRCode(ref, {
                            text, // 需要转换为二维码的内容
                            // width: 400,
                            // height: 400,
                            colorDark: '#000000',
                            colorLight: '#ffffff',
                            correctLevel: 3
                        })

                        setTimeout(() => {
                            let item = document.getElementsByClassName('qrCodeRef')[0].getElementsByTagName('img')[0]
                            if (item) {
                                this.qrcodeImgUrl = item.currentSrc
                            }
                        }, 1000)
                    }
                }, 300)
            },
            // 关闭二维码弹窗
            closeQrCodeModel(e) {
                this.showQrCode = false
                this.editData = null
            },
            // 下载二维码
            downloadCodeImg() {
                let item = this.editData
                let img = document.getElementsByClassName('qrCodeRef')[0].getElementsByTagName('img')[0]
                let imgURL = img.currentSrc
                if (imgURL) {
                    let a = document.createElement('a')
                    a.href = imgURL
                    a.download = (item.customerName || '下载')
                    a.click()
                }
            },
            handleMwExportXls: function() {
                let param = { ...this.queryParam }
                let name = `机构列表-${new Date().FormatDate()}.xls`
                downloadFile(this.url.exportXlsUrl, name, param)
            },
            toPage(item,type){
                if(type == 'apply0'){
                    item['applyType'] = 0;
                    this.$router.push({
                        path: '/jyb_v3/customer/CustomerBusinessApplyForm',
                        query: item
                    });
                }
                if(type == 'apply1'){
                    item['applyType'] = 1;
                    this.$router.push({
                        path: '/jyb_v3/customer/CustomerBusinessApplyForm',
                        query: item
                    });
                }
            },
            onSelectChange1(selectedRowKeys, selectionRows) {
                this.licence = selectionRows[0].licence
                this.businessLicense = selectionRows[0].businessLicense
                this.businessLicenseNumber = selectionRows[0].businessLicenseNumber
                this.licenceNumber = selectionRows[0].licenceNumber
                this.bottomcolval = 1
                this.selectedRowKeys1 = selectedRowKeys
                this.selectionRows1 = selectionRows
                this.model1 = Object.assign({}, selectionRows[0])
                this.currentCustomerNumber = selectionRows[0].customerNumber
                this.currentCustomerName = selectionRows[0].customerName
                // this.loadData2()
                // this.getCustomerImg();
            },


            // 获取医院信息图片
            // async getCustomerImg(){
            //     let params = {
            //         customerNumber : this.currentCustomerNumber,
            //         userName : this.userName
            //     }
            //     this.checkPreImg = null;
            //     let imgList = [];
            //     let res = await getAction('/hc/hcMedicalCare/queryPageList',params)
            //     if (res && res.success) {
            //          let data = res.result || [];
            //          data.forEach((item, index) => {
            //              let obj = {
            //                  index,
            //                  url : `https://www.gzhc.vip/recycle/${item['practisingCertificate']}`,
            //              };
            //              if(index === 0){
            //                  this.checkPreImg = obj;
            //              }
            //              imgList.push(obj)
            //         })
            //     }
            //     this.preImgList = imgList;
            //
            // },
            // beforeChangeCarousel(e){
            //     console.log(e)
            // },
             // 根据医生姓名来查
            // searchUserName(){
            //     this.getCustomerImg();
            // },
            // clickPreImg(index){
            //     this.checkPreImg = this.preImgList[index];
            //
            // 关闭医院、医师信息弹窗
            hideBottomTable() {
                this.bottomcolval = 0
                this.selectedRowKeys1 = []
            }
        }
    }
</script>
<style lang="scss" scoped>

    /*@import  '~@assets/less/common.less';*/
    .ant-radio-button-wrapper-checked{
        background-color: #F2AF06 !important;
    }
    .thumb-example {
        /*height: 330px;*/
    }
    .swiper {
        .swiper-slide {
            /*background-size: cover;*/
            background-position: center;
        }
        &.gallery-top {
            height: 1.2rem;
            width: 60%;
            margin-bottom: 10px;
        }
        /*.next {*/
           /*background-color: white;*/
           /*border-radius: 50%;*/
           /*width: 50px;*/
           /*height: 50px;*/
           /*background-size: 16px 100px;*/
            /*opacity: 0.5;*/

        /*}*/

        &.gallery-thumbs {
            height: 1rem;
            box-sizing: border-box;
            margin-top: 10px;
        }
        &.gallery-thumbs .swiper-slide {
            /*height: 100%;*/
            height: 1.2rem;
            width: 2rem;
            opacity: 0.4;
        }
        &.gallery-thumbs .swiper-slide-active {
            opacity: 1;
        }
        .swiper-zoom-container .img-wrap>img {
            width:150px; height:100px
        }
    }
    .resultMeg{
        color: #fff;
    }




</style>
